<template>
    <div id="AsnDetailList">
        <v-tableTitle :title="$t('wave.orderlist')" :btnConfig="btnConfig" :tableSelectData="selectData" @del="del"></v-tableTitle>
        <div class="detail">
            <component :data="{detailData,argument}" :is="currentComponent"></component>
        </div>
    </div>

</template>

<script>
import tableTitle from "commons/TableTitle";
import navMenu from "commons/NavMenu";
import baseMixin from "@/mixins/BaseMixin";
import config from "../../Config";

export default {
    name: "DetailList",
    mixins: [baseMixin, config],
    data() {
        return {
            newFlag: false,
            detailsFlag: false,
            argument: {},
            detailData: {},
            selectData: [],
            detailNav: "1",
            componentConfig: [
                {
                    name: "detailTable",
                    label: "",
                    component: () => import('./page/detailTable.vue')
                },
                /*{
                    name: "tableDetail",
                    label: this.$t('common.detail'),
                    component: () => import('./page/tableDetail.vue')
                },*/
            ],
        }
    },
    computed: {
        btnConfig() {
            return [
                {label: this.$t('common.delete'), certigier: this.deleteflage, disabled: true, invalid: "del"},
            ]
        },
        currentComponent() {
            return this.componentConfig[this.detailNav - 1].component;
        }
    },
    methods: {
        //删除数据
        async del(data) {
            let str = ""
            if (this.$route.query.queryPageFlag === "querybulider") {
                str = this.argument.interactionid
            } else {
                str = this.argument.filterid
            }
            try {
                let res = await this.$api.post(`/deleteTempOrders/${this.$route.query.queryPageFlag}/${str}`, data);
                
                    this.$message.success(res.returnMgr);
                    this.$children[1].getTableData(1, {})
                
            } catch (e) {
                this.$message.error(e);
            } finally {
                this.$children[1].$refs.table.delSelectData(data);
            }
        },
        //选中的数据
        setSelectData(data) {
            this.selectData = data;
        },
    },
    mounted() {
        this.argument = this.$store.state.routeData;
    },
    components: {
        "v-tableTitle": tableTitle,
        "v-navMenu": navMenu,
    },
    watch: {
        selectData(data) {
            if (this.permissionStatus) {
                if (data.length > 0) {
                    this.deleteflage = false;
                } else {
                    this.deleteflage = false;
                }
            }
        }
    }
}
</script>

<style>

</style>
